package com.wechat.admin.action;

import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.core.action.BaseAction;
import com.wechat.admin.model.Address;
import com.wechat.admin.model.Order;
import com.wechat.admin.model.User;

@Controller
public class loginAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	@RequestMapping(value="/paijian")
	public String paiJian(Address addr, Order order, String openid) {
		User user = null;
		HttpSession session = getRequest().getSession();
		if(session.getAttribute("user") != null){
			user = (User)session.getAttribute("user");
		}else{
			user = new User();
		}
		if(!StringUtils.isEmpty(openid)){
			user.setOpenid(openid);
		}
		if(addr.getPhone() != null){
			user.setAddr(addr);
		}
		if(order.getNumber() != null){
			user.setOrder(order);
		}
		session.setAttribute("user", user);
		return JSP+"paijian";
	}
	
	@RequestMapping(value="/login")
	public String login() {
		return JSP+"login";
	}
	
}
